package base.多线程.扩展JUC;

import java.util.concurrent.TimeUnit;

public class T4 implements Runnable{
    /*测试关闭线程的标志位*/

    private boolean shutdown = false;

    @Override
    public void run() {
        while (!shutdown){
            System.out.println("当前线程1在执行中...");
        }
    }

    public void shutdown(){
        this.shutdown = true;
    }
}

class Text_11{
    public static void main(String[] args) throws InterruptedException {
        T4 t4 = new T4();
        Thread t1 = new Thread(t4);
        t1.start();

        TimeUnit.SECONDS.sleep(5);
        t4.shutdown();
    }
}

